"""
编写人:陈强
"""
# 引入模块
from ecshop.MY_ECShop.common.base import Base,create_loading_browser
import time
# 创建一个会员管理类
class PagevipManage(Base):
    # 定义属性
    url = 'http://localhost:8080/ecshop/admin/'
    num = 0
    vip =('xpath', '//*[@id="menu-ul"]/li[8]')
    vip_list = ('xpath','//*[@id="sub-menu-03_users_list"]/a')
    num_two = 2
    del_vip =('xpath','//*[@id="listDiv"]/table/tbody/tr[3]/td[10]/a[5]')
    add_vip =('xpath','/html/body/h1/a[2]')
    input_vip = ('name','username')
    input_vip_name = 'xiaoqiang'
    mail_vip = ('name','email')
    input_mail_vip = '3303390950@qq.com'
    password_vip = ('name','password')
    input_password_vip = '1234567'
    two_password = ('name','confirm_password')
    click_vip = ('class name','button')
    text_vip = ('xpath','//*[@id="listDiv"]/table/tbody/tr[3]/td[2]')
    # 定义方法
    """输入网址"""
    def page_open(self):
        self.base_open_web(self.url)
    """进入iframe"""
    def page_iframe(self):
        self.base_name_iframe_window(self.num)
    """点击会员管理"""
    def page_vip(self):
        self.base_click(self.vip)
    """点击会员列表"""
    def page_vip_list(self):
        self.base_click(self.vip_list)
    """退出iframe"""
    def page_quit_iframe(self):
        self.base_quit_all_iframe()
    """进入第二层iframe"""
    def page_iframe_two(self):
        self.base_name_iframe_window(self.num_two)
    """点击删除会员"""
    def page_del_vip(self):
        self.base_click(self.del_vip)

    """点击添加会员"""
    def page_add_vip(self):
        self.base_click(self.add_vip)
    """输入会员名称"""
    def page_input_vip(self):
        self.base_input_massage(self.input_vip,self.input_vip_name)
    """输入邮件地址"""
    def page_mail_vip(self):
        self.base_input_massage(self.mail_vip,self.input_mail_vip)
    """输入登陆密码"""
    def page_password(self):
        self.base_input_massage(self.password_vip,self.input_password_vip)
    """确定登陆密码"""
    def page_two_password(self):
        self.base_input_massage(self.two_password,self.input_password_vip)
    """点击确定按钮"""
    def page_click_vip(self):
        self.base_click(self.click_vip)
    """获取文本"""
    def page_text(self):
        return self.base_get_text(self.text_vip)
    """关闭网页"""
    def page_quit(self):
        self.base_quit_web()
if __name__ == '__main__':
    s1 = PagevipManage(create_loading_browser())
    s1.page_open()
    s1.page_iframe()
    s1.page_vip()
    s1.page_vip_list()
    s1.page_quit_iframe()
    s1.page_iframe_two()
    s1.page_add_vip()
    s1.page_input_vip()
    s1.page_mail_vip()
    s1.page_password()
    s1.page_two_password()
    s1.page_click_vip()
    time.sleep(10)
    print(s1.page_text())
    s1.page_quit()